package com.zhb.designmode.creationmode.builder.simple;

public class Phone {

    private String cpu;//必填
    private String screen;//必填
    private Integer camera;
    private String battery;

    private Phone(Builder builder){
        this.cpu = builder.cpu;
        this.screen = builder.screen;
        this.camera = builder.camera;
        this.battery = builder.battery;
    }

    @Override
    public String toString() {
        return "Phone{" +
                "cpu='" + cpu + '\'' +
                ", screen='" + screen + '\'' +
                ", camera=" + camera +
                ", battery='" + battery + '\'' +
                '}';
    }

    public static class Builder{

        private String cpu;//必填
        private String screen;//必填
        private Integer camera;
        private String battery;

        public Builder(String cpu,String screen){
            this.cpu = cpu;
            this.screen = screen;
        }

        public Builder setCamera(Integer camera){
            this.camera = camera;
            return this;
        }
        public Builder setBattery(String battery){
            this.battery = battery;
            return this;
        }
        public Phone build(){
            return new Phone(this);
        }
    }
}
